import BaseGenerator from "./generator/BaseGenerator";

let generatorMap = new Map<string, Map<string, BaseGenerator>>()
let lan = "ts"
function getGeneratorWithName(name : string)
{
	if (generatorMap.has(lan)){
		if (generatorMap.get(lan).has(name)){
			return generatorMap.get(lan).get(name)
		}
	}
	console.error(`[生成器] 生成器不存在: ${name}, ${lan}`)
	return null
}

const generator = function (name, language) {
	return (target, key, descriptor)=>{
		if (!generatorMap.has(language)){
			generatorMap.set(language, new Map<string, BaseGenerator>())
		}
		generatorMap.get(language).set(name, target)
	}
} as any

let GeneratorDecorator = {
	generator : generator,
	getGeneratorWithName : getGeneratorWithName
}

export default GeneratorDecorator